using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using Main;
using UnityEngine;
using ZSW.Framework;

namespace Main.Tree
{
    public class SpriteFader : ZSWF_InitMonoBehaviour, ICanFade
    {
        [SerializeField] private SpriteRenderer[] spriteRenderers;

        public override void Init()
        {
            base.Init();

            spriteRenderers = this.GetComponentsInChildren<SpriteRenderer>();

            if (spriteRenderers == null || spriteRenderers.Length == 0)
            {
                LogError("No sprite renderers found.");
            }
        }



        public void FadeIn(float alpha, float duration)
        {
            foreach (var sr in spriteRenderers)
            {
                sr.DOFade(alpha, duration);
            }
        }

        public void FadeOut(float alpha, float duration)
        {
            foreach (var sr in spriteRenderers)
            {
                sr.DOFade(alpha, duration);
            }
        }

    }
}


